home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_tut / janus32.pkg < prev    next >
Text File  |  1996-01-30  |  3KB  |  61 lines

  1. -- JANUS32.PKG   Ver. 3.00   22-AUG-1994   Copyright 1988-1994 John J. Herro
  2. -- Software Innovations Technology
  3. -- 1083 Mandarin Drive NE, Palm Bay, FL  32905-4706   (407)951-0233
  4. --
  5. -- Compile this before compiling ADA_TUTR.ADA, when using a PC with a 32-bit
  6. -- version of Janus/Ada.
  7. --
  8. with Text2_IO; use Text2_IO;
  9. package Custom_IO is
  10.    type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);
  11.    Foregrnd_Color   : Color := White;                 -- Default values in case
  12.    Backgrnd_Color   : Color := Black;                 -- ADA-TUTR finds no User
  13.    Border_Color     : Color := Black;                 -- File.
  14.    Fore_Color_Digit : Character := Character'Val(Color'Pos(Foregrnd_Color)+48);
  15.    Back_Color_Digit : Character := Character'Val(Color'Pos(Backgrnd_Color)+48);
  16.    Normal_Colors    : String(1 .. 10) := ASCII.ESC & "[0;3" &
  17.                             Fore_Color_Digit & ";4" & Back_Color_Digit & "m";
  18.    Clear_Scrn       : constant String := ASCII.ESC & "[H" & ASCII.ESC &"[2J";
  19.  
  20.    procedure Set_Border_Color (To   : In  Color);
  21.    procedure Get              (Char : out Character);
  22.    procedure Put              (Char : in  Character) renames Text2_IO.Put;
  23.    procedure Put              (Str  : in  String)    renames Text2_IO.Put;
  24.    procedure Put_Line         (Str  : in  String)    renames Text2_IO.Put_Line;
  25.    procedure Get_Line         (Str  : out String;
  26.                                Last : out Natural)   renames Text2_IO.Get_Line;
  27.    procedure New_Line(Spacing : in Positive_Count := 1)
  28.                                                      renames Text2_IO.New_Line;
  29. end Custom_IO;
  30.  
  31. with Doscall, System; use Doscall, System;
  32. package body Custom_IO is
  33.     procedure Set_Border_Color(To : in Color) is
  34.         --
  35.         -- This procedure sets the border color on a PC by calling interrupt
  36.         -- 10 hex.  Before the call, register AH is set to service number
  37.         -- 0B hex, BH is set to zero, and BL is set to an integer as shown in
  38.         -- the declaration of Color_Number below.  Note that the integers in
  39.         -- Color_Number are bit reversed from the integers defining foreground
  40.         -- and background colors in ANSI escape sequences.  Note also that some
  41.         -- color PCs don't have separate border colors.
  42.         --
  43.         Regs         : Simple_Regs;
  44.         Color_Number : constant array(Color) of Long_Integer :=
  45.             (Black   => 0,   Red     => 4,   Green   => 2,   Yellow  => 6,
  46.              Blue    => 1,   Magenta => 5,   Cyan    => 3,   White   => 7);
  47.     begin
  48.         Regs.EAX := 16#0B00#;
  49.         Regs.EBX := 16#0000# + Color_Number(To);
  50.         Simple_Int_Call(Int_Num => 16#10#, Regs => Regs);
  51.     end Set_Border_Color;
  52.  
  53.     procedure Get(Char : out Character) is
  54.         Regs : Simple_Regs;
  55.     begin
  56.         Regs.EAX := 16#0800#;
  57.         Simple_Int_Call(Int_Num => 16#21#, Regs => Regs);
  58.         Char := Character'Val(Regs.EAX mod 128);
  59.     end Get;
  60. end Custom_IO;
  61.